package com.example.commands;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.example.service.UserService;
import com.example.vo.UserVO;

import cn.hutool.json.JSONUtil;

@Component
public class UserTask implements CommandLineRunner {

//	@DubboReference
//	private UserService userService;

	@Autowired
	@Qualifier("userServiceExt")
	private UserService userService;

//	@Autowired
//	private GenericService genericUserService;

	@Override
	public void run(String... args) throws Exception {
		UserVO user = userService.profile("simple");
//		UserVO user =genericUserService.$invoke("profile", "sim");

//		System.out.println("consumer.point.receive result ======> " + JSONUtil.toJsonStr(user));
		
		
//		genericHelloService.$invoke(null, args, args)

		new Thread(() -> {
			while (true) {
				try {
					Thread.sleep(3000);
					System.out.println(new Date() + "consumer.point.receive result ======> "
							+ JSONUtil.toJsonStr(userService.profile("simp")));
				} catch (InterruptedException e) {
					e.printStackTrace();
					Thread.currentThread().interrupt();
				}
			}
		}).start();
	}
}